/*
 * @Author: long
 * @Date: 2021-08-10 14:49:42
 * @LastEditTime: 2021-11-09 16:29:46
 * @LastEditors: Please set LastEditors
 * @Description: 资源管理
 * @FilePath: \workspace\hjimi2\facecloudwebsite\src\api\face-recognition\resource-manage.js
 */

import request from '@/utils/request'

const RESOURCE = 'api/v1/charge/api/',
      RESOURCE1 = 'api/v1/charge/',
      HEADERS = { 'Content-Type': 'application/json' }

/**
 * @description: 按调用次数购买的价格列表
 * @param {number} id
*/
 export function quantityPayList(id) { return request({ url: `${ RESOURCE }resource/${ id }/price/quantity`, method: 'GET' })}

 /**
 * @description: 按调用次数购买的价格列表
 * @param {number} id
 * @param {string} purchaseType 可选值（day, mounth）按天/按月
*/
export function qpsPayList(id, purchaseType) { return request({ url: `${ RESOURCE }resource/${ id }/price/qps/${ purchaseType }`, method: 'GET' })}

/**
 * @description: 服务可用资源列表
 */
export function listServiceResourceList() { return request({ url: `${ RESOURCE }resource/listServiceResourceList?serviceId=1`, method: 'GET' }) }

/**
 * @description: 资源购买调用量计费
 */
 export function billingForResourcePurchasesAndCalls(data) { return request({ url: `${ RESOURCE1 }billingForResourcePurchasesAndCalls`, method: 'POST', data, headers: HEADERS })}

/**
 * @description: 资源购买QPS计费
 */
 export function resourcePurchaseQpsBilling(data) { return request({ url: `${ RESOURCE1 }resourcePurchaseQpsBilling`, method: 'POST', data, headers: HEADERS })}

/**
 * @description: 资源调用按量计费信息
 */
 export function resourceCallVolumeBillingInformation(id) { return request({ method: 'GET', url: `${ RESOURCE }resource/resourceCallVolumeBillingInformation/${id}`, })}

/**
 * @description: 资源调用按QPS计费信息
 */
 export function resourceQpsChargingInformation(id, type) { return request({ method: 'GET', url: `${ RESOURCE }resource/resourceQpsChargingInformation/${id}/${type}`, })}

 /**
  * @description: 提交订单
  * @param {Object} data
  */
 export function placeOrder (data) { return request({ url: `${ RESOURCE }order`, method: 'POST', data, headers: HEADERS }) }

/**
 * @description: 支付订单付款
 */
 export function orderPayment(data) { return request({ url: `${ RESOURCE1 }orderPayment`, method: 'POST', data, headers: HEADERS })
}

/**
 * @description: 微信查询订单
 */
 export function queryOrder(orderNumber, type) {
  // let handleUrl = type == 1 ? 'api/v1/payment/queryOrder' : '/api/v1/pay/tradeQuery'
  let handleUrl = type == 1 ? 'cloud-platform-payment/api/v1/payment/queryOrder' : 'cloud-platform-payment/tradeQuery'
  return request({
    url: `${handleUrl}`,
    method: 'POST',
    data: {
      "businessName": "辨识云付费业务",
      "nonce": "",
      "outTradeNo": orderNumber,
      "ownershipId": "admin",
      "sign": "",
      "timestamp": ""
    },
    headers: HEADERS
  })
}